from vehicle import Vehicle

class Car(Vehicle):
    pass

class Bus(Vehicle):
    route_number = "B667"  
    route_list = ["留仙洞地铁站", "石鼓花园", "鹏城实验室", "中兴人才公寓东", "深职院留仙洞校区"]  # 默认路线列表
    running = False  # 新增属性，表示车辆是否启动
    bus

    def info(self):  # 输出车辆信息
        super().info()
        print(f"Route Number: {self.route_number}")
        print(f"Route List: Next station is {self.route_list}")
        return

    def set_route(self, new_route_list):  # 设置新的路线列表
        self.route_list = new_route_list

    def broadcast(self):  # 报站功能
        if self.running:
            print(f"Next stop is: {self.route_list[0]}")
            # 假设车辆每到一站，路线列表中的下一个站点就会成为第一个站点
            self.route_list = self.route_list[1:] + [self.route_list[0]]
        else:
            print("Cannot broadcast, the bus is not running.")

    def run(self, speed):  # 启动车辆
        if speed <= self.maxspeed:
            self.running = True
            print(f"The bus is running at {speed} km/h")
            self.broadcast()  # 启动时进行报站
        else:
            print(f"Speed {speed} km/h exceeds the max speed of {self.maxspeed} km/h.")

    def stop(self):  # 停止车辆
        self.running = False
        print("The bus has stopped.")

# 注意：在实际的类定义中，你需要确保 Vehicle 类中有一个合适的 info 方法，以及 maxspeed 属性。
# 另外，run 方法中的 speed 参数需要根据 Vehicle 类的设计来适当使用。


class Truck(Vehicle):   #卡车类（载重量，最高速）
    maxspeed = 120
    def info(self):   #输出车辆信息
        super().info()
        print(f"Truck Load Capacity: {self.loadcap}Ton")
        return
    
    def __init__(self,vinfo,loadcap):   #初始化车辆信息
        super().__init__(vinfo)
        self.loadcap = loadcap
        return  


def main():
    car1_info = {"brand":"Audi","number":"粤B12345","color":"White"}
    car1 = Car(car1_info)
    car1.info()
    car1.run(160)

    truck1_info = {"brand":"Dongfeng","number":"粤A54321","color":"White"}
    load_cap = 100
    truck1 = Truck(truck1_info,load_cap)
    #truck1 = Truck(car1Info)
    truck1.info()
    truck1.run(160)




if __name__ == "__main__":
    main()
